!function () { function clear(text) { return text.length ? text.replace(/\s{2,}/g, ' ').replace(/^\s|\s$/g, '') : ''; } window.scrollTo = function (selectButs, selectBox, duration, indent) { indent = indent || 0; duration = duration || 500; box = function (element) { return element.getBoundingClientRect().top + window.pageYOffset - indent }; callback = (typeof selectBox === 'function') ? selectBox : box(document.querySelector(selectBox)); function scrolls(to) { var globalBox = document.scrollingElement || document.documentElement, start = globalBox.scrollTop, change = to - start, startDate = +new Date(), easeInOutQuad = function (t, b, c, d) { t /= d / 2; if (t < 1) return c / 2 * t * t + b; t--; return -c / 2 * (t * (t - 2) - 1) + b; }, animateScroll = function () { var currentDate = +new Date(); var currentTime = currentDate - startDate; globalBox.scrollTop = parseInt(easeInOutQuad(currentTime, start, change, duration)); if (currentTime < duration) { requestAnimationFrame(animateScroll); } else { globalBox.scrollTop = to; } }; animateScroll(); } var buttons = document.querySelectorAll(selectButs); for (i = 0; i < buttons.length; i++) { buttons[i].addEventListener('click', function () { scrolls(callback(this)) }); } }; window.scrollTo('[data-go]', function (e) { var id = e.getAttribute('data-go'); var nav = document.querySelector('[data-action]'); if (listBox.indexOf(id) >= 0) nav.setAttribute('data-action', id); nav.classList.add('off'); setTimeout(function () { nav.classList.remove('off'); if (listBox.indexOf(id) < 0) actionBox(); }, 510); if (id === 'home') menuBox.classList.remove('open'); return box(document.querySelector('.' + id)); }, 500, 102); // var menuBox = document.querySelector('.navigation'); // var menuBurg = document.querySelector('.navigation__burg'); // var menuBut = document.querySelectorAll('.navigation__item[data-go]'); var anim = document.querySelectorAll('[data-animation]'); // var listBox = ['home']; // for (var i = 0; i < menuBut.length; i++) { // var id = menuBut[i].getAttribute('data-go'); // if (listBox.indexOf(id) < 0) listBox.push(id); // menuBut[i].addEventListener('click', function () { // menuBox.classList.remove('open'); // }); // } // function actionBox() { // var nav = document.querySelector('[data-action]'); // } anim.forEach(function (el) { var id = el.getAttribute('data-animation'); var text, word, index = 0; switch (id) { case 'symbol': text = clear(el.innerHTML); if (text.length) { word = text.split(' '); index = 0; word.forEach(function (symbol, i) { var dopCss = ''; if (/^#(.*)#$/.test(symbol)) { symbol = symbol.replace(/^#(.*)#$/, '$1'); dopCss = ' redColor'; } symbol = symbol.split(''); symbol.forEach(function (_symbol, _i) { symbol[_i] = '' + _symbol + ''; index++; }); word[i] = '' + symbol.join('') + ''; }); el.innerHTML = word.join(' '); } break; case 'text': text = clear(el.innerHTML); if (text.length) { word = text.split(' '); word.forEach(function (symbol, i) { word[i] = '' + symbol + ''; }); el.innerHTML = word.join(' '); } break; } }); function scrollShow() { anim.forEach(function (el) { var id = el.getAttribute('data-animation'); if (id === 'text') { var box = el.querySelectorAll('.__anim__box'); box.forEach(function (_el) { if (!_el.classList.contains('__anim-show') && (0 >= _el.getBoundingClientRect().top - window.innerHeight / 1.2)) { _el.classList.add('__anim-show') } }); } else if (!el.classList.contains('__anim-show') && (0 >= el.getBoundingClientRect().top - window.innerHeight / 1.2)) { el.classList.add('__anim-show') } }); } function scrollFun() { // actionBox(); scrollShow(); } scrollFun(); document.addEventListener('scroll', scrollFun); window.addEventListener('resize', scrollFun); // var body = document.querySelector('body'); }(); // Add subtitles function AddSubtitles() { const video = document.querySelectorAll('.avid'); const subtitles = document.querySelectorAll('.subtitles'); for (let i=0; i < video.length; i++) { video[i].innerHTML += subtitles[i].innerHTML; } } setTimeout(()=>{ AddSubtitles(); }, 100);